package com.ymttest.common.order.sellerquery2.sp;

import java.util.List;
import java.util.Map;

import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtOOrderNoteWapper;
import com.ymttest.database.sqlwapper.YmtOrdersWapper;
import com.ymttest.utils.DataUtil;

/**
 * 存储过程<br>
 * sp_trd_GetExportOrderInfoByOrderIds_v1
 * 
 * @author songyefeng
 *
 */
public class Sp_GetExportOrderInfoByOrderIds_v1 {
	private List<Integer> orderIds;
	private int sellerId;

	public Sp_GetExportOrderInfoByOrderIds_v1(List<Integer> orderIds,
			int sellerId) {
		this.orderIds = orderIds;
		this.sellerId = sellerId;
	}

	// --Orders Detailed Information
	@SuppressWarnings("rawtypes")
	public List<Map> getOrders() {
		List<Map> result = null;
		if (false == DataUtil.isNullOrEmpty(orderIds)) {
			String queryField = "iOrderId , fFreight , fOrderPrice , iTradingStatus , iRiskVerifiedStatus , "
					+ "bPaidInFull , dAddTime , dPaidTime , dApplyPostPayTime , dDispathTime , sLeaveWord , "
					+ "sBuyerLoginId , sReceivePerson , sPhone , sTelephone , sAddress , sPostCode , "
					+ "bShangouOrder , bDomesticDelivered , dPostPaidTime";
			result = new YmtOrdersWapper().selectOrders2(queryField, null,
					"iOrderId in " + DataUtil.toInOfSql(orderIds));
		}
		return result;
	}

	// --Products Detailed Information
	@SuppressWarnings("rawtypes")
	public List<Map> getOrderInfos() {
		List<Map> result = null;
		if (false == DataUtil.isNullOrEmpty(orderIds)) {
			String queryField = " iOrderId , iCatalogStatus , iCatalogType , sTitle , iAmount , fOriginalPrice , sSKU , sPropertyInfo , iCatalogStatus , iCatalogType , iBondedArea, sCatalogId = case when sCatalogId is null then null else '1' end ";
			result = new DefaultWapper().selectOrderInfo(queryField, null,
					" iOrderId in " + DataUtil.toInOfSql(orderIds));
		}
		return result;
	}

	// --Orders Note Detailed Information
	@SuppressWarnings("rawtypes")
	public List<Map> getOrderNotes() {
		List<Map> result = null;
		if (false == DataUtil.isNullOrEmpty(orderIds)) {
			result = new YmtOOrderNoteWapper().selectOrderNotes(
					"note.iOrderId , note.sContent, note.iRemarkLevel", null,
					"note.iOrderId in " + DataUtil.toInOfSql(orderIds)
							+ " and iUserId = " + sellerId);
		}
		return result;
	}

	// --Orders State Detailed Information
	@SuppressWarnings("rawtypes")
	public List<Map> getOrderStates() {
		List<Map> result = null;
		if (false == DataUtil.isNullOrEmpty(orderIds)) {
			result = new DefaultWapper().selectOrderStatesByOrderIds("*", null,
					"state.iOrderId in " + DataUtil.toInOfSql(orderIds));
		}
		return result;
	}

	// --获取订单物流信息
	@SuppressWarnings("rawtypes")
	public List<Map> getOrderSummarys() {
		List<Map> result = null;
		if (false == DataUtil.isNullOrEmpty(orderIds)) {
			result = new DefaultWapper().selectOrderSummary2(
					"iOrderId , sLogisticsProvider , sSummary", null,
					"summary.iOrderId in " + DataUtil.toInOfSql(orderIds));
		}
		return result;
	}
}
